<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<body>


	<h:form id="buyForm">

		<h2>Product details</h2>

		<p:outputPanel>
			<h:panelGrid columns="3" id="regGrid">
				<h:outputLabel for="email">Email:</h:outputLabel>
				<p:inputText id="email" value="#{buyBean.user.email}" />
				<p:message for="email" />

				<h:outputLabel for="firstName">First name:</h:outputLabel>
				<p:inputText id="firstName" value="#{buyBean.user.firstName}" />
				<p:message for="firstName" />

				<h:outputLabel for="lastName">Last name:</h:outputLabel>
				<p:inputText id="lastName" value="#{buyBean.user.lastName}" />
				<p:message for="lastName" />

			</h:panelGrid>
		</p:outputPanel>

		<h:outputLabel> You are about to buy the following product:</h:outputLabel>

		<p:outputPanel id="buyFormVolo"
			rendered="#{buyBean.searchedProd == 'flight' }">

			<h5>
				<h:outputText value="#{buyBean.volo.compagnia} - #{buyBean.volo.id}" />
			</h5>
			<h6>When?</h6>
			<h:outputText value="departure: #{buyBean.volo.dataInizio}" />
			<br />
			<h:outputText value="return: #{buyBean.volo.dataFine}" />

			<h6>Where?</h6>
			<h:outputText value="departure city: #{buyBean.volo.citta_partenza}" />
			<br />
			<h:outputText value="arrival city: #{buyBean.volo.citta_arrivo} " />

			<h5>Who?</h5>
			<h:outputText value="guests: #{buyBean.guests}" />

			<h5>How much?</h5>
			<h:outputText value="total: #{buyBean.volo.prezzo}" />

			<p:commandButton value="Buy" update="buyForm"
				action="#{buyBean.buyVolo()}" oncomplete="PF('acquista').show()"
				style="margin-top: 20px" />

		</p:outputPanel>

		<p:outputPanel id="buyFormHotel"
			rendered="#{buyBean.searchedProd == 'hotel' }">


			<h5>
				<h:outputText
					value="#{buyBean.hotel.nome} - #{buyBean.hotel.stelle} stars" />
			</h5>
			<h6>When?</h6>
			<h:outputText value="from: #{buyBean.hotel.dataInizio}" />
			<br />
			<h:outputText value="till: #{buyBean.hotel.dataFine}" />

			<h6>Where?</h6>
			<h:outputText value="city: #{buyBean.hotel.citta}" />

			<h5>Who?</h5>
			<h:outputText value="guests: #{buyBean.guests}" />

			<h5>How much?</h5>
			<h:outputText value="total: #{buyBean.hotel.prezzo}" />

			<p:commandButton value="Buy" update="buyForm"
				action="#{buyBean.buyHotel()}" oncomplete="PF('acquista').show()"
				style="margin-top: 20px" />

		</p:outputPanel>

		<p:outputPanel id="buyFormEscursione"
			rendered="#{buyBean.searchedProd == 'excursion' }">


			<h5>
				<h:outputText value="Excursion code: #{buyBean.escursione.id}" />
			</h5>
			<h6>When?</h6>
			<h:outputText value="start date: #{buyBean.escursione.dataInizio}" />
			<br />
			<h:outputText value="time: #{buyBean.escursione.oraInizio}" />
			<br />
			<h:outputText value="end date: #{buyBean.escursione.dataFine}" />

			<h6>Where?</h6>
			<h:outputText value="city: #{buyBean.escursione.citta}" />

			<h5>Who?</h5>
			<h:outputText value="guests: #{buyBean.guests}" />

			<h5>How much?</h5>
			<h:outputText value="total: #{buyBean.escursione.prezzo}" />

			<p:commandButton value="Buy" update="buyForm"
				action="#{buyBean.buyEscursione()}"
				oncomplete="PF('acquista').show()" style="margin-top: 20px" />

		</p:outputPanel>

		<p:dialog id="acquista" header="Transaction details"
			widgetVar="acquista" resizable="false" width="500" showEffect="fade"
			hideEffect="fade">
			<p:outputLabel>Product successfully bought!</p:outputLabel>
		</p:dialog>

	</h:form>











</body>
</html>
